package classes
{
import flash.geom.ColorTransform;

import mx.core.Application;
	
[Bindable] public class User
	{
		public var id:String;
		public var username:String;
		public var sex:String="m";
		public var room:String="lobby";
		public var webcam:String= "false";
		public var isRoomOwner:Boolean = false;
		public var myCar:Car;
		 
		public function User(id:String, username:String, sex:String, room:String, webcam:String )	{
			this.id = id;
			this.username = username;
			this.sex = sex;
			this.room = room;
			this.webcam = webcam;
			this.isRoomOwner = false;
		}
		public function removeCar():void {
			if (myCar!=null) {
				Application.application.track1.removeChild(myCar);
			}				
		}
		public function prepareCar():void {
			removeCar();
			myCar = new Car();
			//Application.application.rawChildren.addChild(this.myCar);
			Application.application.track1.addChild(myCar);			
			
			this.myCar.username = this.username;
			if (this.username!=Application.application.myuser.username) {
				var ct:ColorTransform = new ColorTransform();
				ct.color = 0xFF0000;
				this.myCar.transform.colorTransform = ct;
				this.myCar.alpha=0.5;
			}
			if (isRoomOwner) {
				this.myCar.x = 550;
				this.myCar.y = 220;
			} else {
				this.myCar.x = 570;
				this.myCar.y = 220;				
			}			
		}
		

	}
}